// JavaScript Document

/* THESE ARE THE ULTIMATE GLOBAL VARS */

var urlThrive = "http://cmer2.socs.uoguelph.ca/mhealth/ThriveServer/";
var TEST_DEVICE = "1234567";
var USER_NAME = "";

/* GlOBAL VARIABLES ABOOUT ACCOUNT INFO */

var DEBUG_ALERTS = false;

var DATA_SHARE = "false";
var BIRTHDATE = "";
var GRADE = "";
var SEX = "";
var ETHNICITY = "";
var PARENT1 = "";
var PARENT2 = "";
var TOUCHSCREEN = "";
var USE = "";


$(document).bind("mobileinit", function(){
      $.mobile.defaultPageTransition = 'none';
      $.mobile.defaultDialogTransition = 'none';
      $.mobile.useFastClick = true;
	  $.mobile.page.prototype.options.domCache = true;
});

function index_prefetch() {

	$.mobile.loadPage( "../Components/Feel/feel.html", { showLoadMsg: false } );
	$.mobile.loadPage( "../Components/Believe/believe.html", { showLoadMsg: false } );
	<!---$.mobile.loadPage( "../Components/Breathe/breathe.html", { showLoadMsg: false } );-->
	$.mobile.loadPage( "../Components/Shine/shine.html", { showLoadMsg: false } );
	$.mobile.loadPage( "../Components/Gather/gather.html", { showLoadMsg: false } );
	$.mobile.loadPage( "../Components/Grow/grow.html", { showLoadMsg: false } );
	$.mobile.loadPage( "../Components/MindMap/mindmap.html", { showLoadMsg: false } );
	$.mobile.loadPage( "../Components/AccountControl/account.html", { showLoadMsg: false } );
	$.mobile.loadPage( "../Components/AccountControl/login.html", { showLoadMsg: false } );
}

function showPopup(message) {

	removePopup();
	var width = window.innerWidth;
	var popupWidth = (width / 100) * 90;
	var left = (width - popupWidth) / 2;
	
	$('.popup').append(message);
	$('.popup_container').attr("style", "width:"+popupWidth+"px;"+"left:"+left+"px;");
}

function showPopup(message, top) {

	removePopup();
	var width = window.innerWidth;
	var popupWidth = (width / 100) * 90;
	var left = (width - popupWidth) / 2;
	
	$('.popup').append(message);
	$('.popup_container').attr("style", "width:"+popupWidth+"px;"+"top:"+top+"px;"+"left:"+left+"px;");
}

function getTimeStamp() {

	var date = new Date();
	
	var month = date.getMonth() + 1;
	var timeStamp = date.getFullYear() + "-" + month + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();

	return timeStamp;
}

$(".popup_container").live('click', function() {
	removePopup();
});

$(".popup_container").live('tap', function() {
	removePopup();
});

$(".popup_container").bind('touchstart', function()  {
	removePopup();
});


function removePopup() {
	$('.popup').html("");
	$('.popup_container').attr("style", "display:none;");
}